#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import exact_diagonalization
import ConfigParser
import sys
import numpy
import cPickle as pickle

B = float( sys.argv[ sys.argv.index('-B') + 1] )

config = ConfigParser.RawConfigParser()
config.read('config.py') #opening configuration file
modelname = 'Triangular_transverse_2d'
ferromagnetic = config.getboolean(modelname, 'ferromagnetic')

if ferromagnetic:
    case = 'ferromagnetic'
    J = 1
else:
    case = 'antiferromagnetic'
    J = -1

neighbors = eval(config.get( modelname, 'horizontal neighbours'))


N = eval(config.get(modelname, 'horizontal shape'))[0] 
H = exact_diagonalization.Hamiltonian(neighbors, N)
fName = os.path.join('accurate_data', modelname, case, 'N{0}_J{1}_B{2}'.format(N, J, B))
fName = open(fName, 'w')


eig = numpy.linalg.eig(H.matrix_gen(J, B))

pickle.dump(eig, fName)